package com.yanqu.road.server.cmd.activity.stronghold.eliminate;

import com.yanqu.road.entity.union.cross.CrossUnionMember;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.server.manger.union.GameUnionActivityGroupMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

import java.util.Map;

@Cmd(code = GameProtocol.S_CROSS_STRONGHOLD_MAMMON_HELP_BROADCAST, desc = "")
public class StrongholdMammnoHelpBroadcastCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        StrongholdWarProto.StrongholdNoticeMammonHelpMsg msg = StrongholdWarProto.StrongholdNoticeMammonHelpMsg.parseFrom(packet.getBytes());
        long userId = msg.getUserId();
        int activityId = StrongholdActivityMgr.getActivityInfo().getActivityId();
        int groupId = GameUnionActivityGroupMgr.getGroupId(activityId, userId);
        for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
            if (GameUnionActivityGroupMgr.getGroupId(activityId, player.getUserId()) == groupId) {
                player.sendPacket(Protocol.U_STRONGHOLD_MAMMON_HELP_NOTICE, msg.toBuilder());
            }
        }
    }
}
